import { useState, useEffect, useMemo } from "react";

export default function () {
    const [count, setCount] = useState(0);
    const [a, setA] = useState(0);

    useEffect(() => {
        setTimeout(() => {
            setCount(0);
            setA(a + 1);
        }, 1000);
    }, [count, a]);

    // hooks没有shouldComponentUpdate
    // 只能useMemo
    return useMemo(() => {
        console.log('render');
        return <>{ count }</>;
    }, [count]);

}
